// import type { ConsultType } from '@/enums'
// import type { PartialConsult } from '@/types/consult'
// import { defineStore } from 'pinia'
// import { ref } from 'vue'

import type { ConsultType } from '@/enums'
import type { PartialConsult } from '@/types/consult'
import { defineStore } from 'pinia'
import { ref } from 'vue'

// export const useConsultStore = defineStore(
//   'cp-consult',
//   () => {
//     const consult = ref<PartialConsult>({})
//     // 设置问诊类型
//     const setType = (type: ConsultType) => (consult.value.type = type)
//     // 设置极速问诊类型
//     const setIllnessType = (type: 0 | 1) => (consult.value.illnessType = type)
//     // 设置科室
//     const setDep = (id: string) => (consult.value.depId = id)
//     // 设置病情描述
//     const setIllness = (
//       illness: Pick<PartialConsult, 'illnessDesc' | 'illnessTime' | 'consultFlag' | 'pictures'>
//     ) => {
//       consult.value.illnessDesc = illness.illnessDesc
//       consult.value.illnessTime = illness.illnessTime
//       consult.value.consultFlag = illness.consultFlag
//       consult.value.pictures = illness.pictures
//     }
//     // 设置患者
//     const setPatient = (id: string) => (consult.value.patientId = id)
//     // 设置优惠券
//     const setCoupon = (id?: string) => (consult.value.couponId = id)
//     // 清空记录
//     const clear = () => (consult.value = {})
//     return { consult, setType, setIllnessType, setDep, setIllness, setPatient, setCoupon, clear }
//   },
//   {
//     persist: true
//   }
// )

export const useConsultStore = defineStore(
  'cp-consult',
  () => {
    // 组装PartialConsult数据
    const consult = ref<PartialConsult>({})
    // 点击极速问诊 ConsultType指的是枚举中的类型，1为找医生，2，极速问诊，3开药问诊
    const setType = (type: ConsultType) => (consult.value.type = type)

    // 设置就诊类型
    const setIllnessType = (illnessType: 0 | 1) => (consult.value.illnessType = illnessType)

    // 设置科室
    const setDep = (id: string) => (consult.value.depId = id)

    // 病情描述，此页面四个选项 症状描述 - 多久了 - 是否就过诊 - 图片
    const setIllness = (
      illness: Pick<PartialConsult, 'illnessDesc' | 'illnessTime' | 'consultFlag' | 'pictures'>
    ) => {
      consult.value.illnessDesc = illness.illnessDesc
      consult.value.illnessTime = illness.illnessTime
      consult.value.consultFlag = illness.consultFlag
      consult.value.pictures = illness.pictures
    }

    // 设置患者
    const setPatient = (id: string) => (consult.value.patientId = id)
    // 设置优惠券
    const setCoupon = (id?: string) => (consult.value.couponId = id)
    // 清空
    const clear = () => (consult.value = {})
    return {
      consult,
      setType,
      setIllnessType,
      setDep,
      setIllness,
      setPatient,
      setCoupon,
      clear
    }
  },
  { persist: true }
)
